Skip to content

fix(rpc): respect commitment visibility in getBlock#572

Merged
MicaiahReid merged 1 commit intosolana-foundation:mainfrom
Lightprotocol:sergey/getblock-commitment-fix
Mar 18, 2026
Merged

fix(rpc): respect commitment visibility in getBlock#572
MicaiahReid merged 1 commit intosolana-foundation:mainfrom
Lightprotocol:sergey/getblock-commitment-fix

Conversation

@sergeytimoshin
Copy link
Contributor

Summary

Make getBlock enforce the requested commitment’s visible slot range before returning a block.

Today, Surfpool applies commitment-based visibility in getSlot, but getBlock(slot, commitment=...) can still serve a slot newer than that commitment should allow. This patch makes getBlock return None when the requested slot is newer than get_slot_for_commitment(commitment).

Why

A client asking for confirmed or finalized block data should not be able to observe a block from a newer slot than that commitment permits.

In our case, this showed up downstream as an inconsistent block stream for indexing: clients could persist blocks up to sequence N, then later receive a block view containing N+2/N+3 while the missing intermediate slot(s) were not yet visible at the same commitment.

Changes

  • In crates/core/src/surfnet/locker.rs:
    • compute the committed slot using get_slot_for_commitment(...)
    • if the requested slot is newer than that committed slot, return None
  • In crates/core/src/rpc/full.rs:
    • add a regression test that verifies a confirmed getBlock request does not expose the latest absolute slot

Test

cargo test --manifest-path Cargo.toml -p surfpool-core
test_get_block_respects_confirmed_commitment_visibility -- --nocapture

Copy link
Collaborator

@MicaiahReid MicaiahReid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks @sergeytimoshin!

@MicaiahReid MicaiahReid merged commit d48c340 into solana-foundation:main Mar 18, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants